/*
 * --------------------------------------------------------------
 * Copyright ©  2015 Hangzhou DtDream Technologies Co.,Ltd.
 * --------------------------------------------------------------
 *      Product: 协同数治
 *  Module Name: design
 * Date Created: 2022/12/15
 *  Description: TODO
 * --------------------------------------------------------------
 * Modification History
 * DATE            NAME            Description
 * --------------------------------------------------------------
 * 2022/12/15       yewj            TODO
 * --------------------------------------------------------------
 */

package com.dtdream.principle.liskov;

/**
 * 里氏替换原则
 *
 * @Author: yewj
 **/
public class Likov {
    public static void main(String[] args) {
        A a = new A();
        System.out.println("11-3=" + a.func1(11, 3));
        System.out.println("1-8=" + a.func1(1, 8));

        System.out.println("---------------------------------");
        B b = new B();
        System.out.println("11-3=" + b.func1(11, 3));
        System.out.println("1-8=" + b.func1(1, 8));
        System.out.println("11+3+9=" + b.func2(11, 3));

    }
}

class A {
    public int func1(int num1, int num2) {
        return num1 - num2;
    }
}


class B extends A {

    @Override
    public int func1(int a, int b) {
        return a + b;
    }

    /**
     * 增加了个新功能，完成两个数相加，然后和9求和
     * @param a
     * @param b
     * @return
     */
    public int func2(int a, int b) {
        return func1(a, b) + 9;
    }
}
